import requests
from untils.mylogger import logger

'''封装requests请求'''

class MyRequests:
    def __init__(self):
        self.logger = logger

    def go_request(self,method,url,parmes = None,heaeder =None,data =None,josn =None,**kwargs):
        if method == 'get':
            r = requests.get(url=url,headers=heaeder,params=parmes)
            self.logger.debug(f'请求路径{url},请求头{heaeder},请求入参{parmes}')
            self.logger.debug(f'返回状态码{r.status_code},返回参数{r.text}')
            return r

        elif method == 'post':
            r = requests.post(url=url,headers=heaeder,data=data,json=josn,**kwargs)
            self.logger.debug(f'请求路径{url},请求头{heaeder},请求入参{data},{josn}')
            self.logger.debug(f'返回状态码{r.status_code},返回参数{r.text}')
            return r



